package com.mark.article.controller.v2;

import com.mark.article.apis.ArticleSearchControllerApi;
import com.mark.article.service.ApArticleSearchService;
import com.mark.model.article.dtos.UserSearchDto;
import com.mark.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description :  java类作用描述
 * @Author :  Markburt
 * @CreateDate :  2020/3/7$ 下午 02:28$
 * @UpdateUser :  Markburt
 * @UpdateDate :  2020/3/7$ 下午 02:28$
 * @UpdateRemark :  Project Build
 * @Version :  1.0
 */
@RestController
@RequestMapping("/api/v2/article/search")
public class ArticleSearchV2Controller implements ArticleSearchControllerApi {

    @Autowired
    private ApArticleSearchService apArticleSearchService;


    /***
     *查询搜索历史
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/load_search_history")
    public ResponseResult findUserSearch(@RequestBody UserSearchDto dto) {
        return apArticleSearchService.findUserSearch(dto);
    }


    /**
     *删除搜索历史
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/del_search")
    public ResponseResult delUserSearch(@RequestBody UserSearchDto dto) {
        return apArticleSearchService.delUserSearch(dto);
    }


    /***
     *清空搜索历史记录
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/clear_search")
    public ResponseResult clearUserSearch(@RequestBody UserSearchDto dto) {
        return apArticleSearchService.clearUserSearch(dto);
    }


    /**
     *今日热词
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/load_hot_keywords")
    public ResponseResult hotkeywords(@RequestBody UserSearchDto dto) {
        return apArticleSearchService.hotkeywords(dto.getHotDate());
    }

    /**
     *搜索联想词 V2
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/associate_search")
    public ResponseResult searchassociate(@RequestBody UserSearchDto dto) {
        return apArticleSearchService.searchAssocicationV2(dto);
    }


    /**
     *es文章分页查询
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/article_search")
    public ResponseResult esArticleSearch(@RequestBody UserSearchDto dto) {
        return apArticleSearchService.esArticleSearch(dto);
    }
}
